tab = readtable('uk_graph2-1_resid2.csv');
tab = table2array(tab);

% Fig1
% figure('position', [0, 0, 800, 300])
figure('position', [0, 0, 800, 400])
tiledlayout(2,1,'TileSpacing','Compact','Padding','Compact');

% subplot(1,2,1)
% subplot(2,1,1)
nexttile

yyaxis left
plot(tab(:,1), tab(:,10),'LineWidth',1.2);
ylim([0.1, 1.1]);

yyaxis right
plot(tab(:,1), tab(:,9),'LineWidth',1.2);
ylim([-0.03, 0.06]);
hold on

bands = [1938.5, 1939; 1940.25, 1941.25; 1951.25, 1953.25; 1955, 1959; 1959.5, 1960.75; 1961, 1962; 1962.25, 1963.25; ...
         1966.5, 1967.5; 1968.25, 1968.5; 1968.75, 1978.75; 1979.75, 1981; 1982.25, 1982.75; 1983.25, 1983.5; 1984, 1987; 1987.75, 1988.75; ...
         1990, 1992; 1997, 1998; ...
         1998.5, 1999.75; 2000, 2004; 2008, 2011; 2011.5, 2012.5; 2013, 2014; 2015.5, 2015.75; 2016, 2016.25; 2018, 2019];

xp = [bands fliplr(bands)];
yp = ([[1;1]*min(ylim); [1.2;1.2]*max(ylim)]*ones(1,size(bands,1))).';
for k = 1:size(bands,1)                                                             
    patch(xp(k,:), yp(k,:), [1 1 1]*0.1, 'FaceAlpha', 0.2, 'LineStyle', 'none')
end

ax = gca;
ax.YAxis(1).Color = 'k';
ax.YAxis(2).Color = 'k';

xlim([1935 2020]);
xlabel('Date');
legend('Debt-to-GDP (left)', 'Foreign volatility (right)')
title('a) Debt and Foreign Volatility');

% subplot(1,2,2)
% subplot(2,1,2)
nexttile

yyaxis left
plot(tab(:,1), tab(:,5),'LineWidth',1.2);
% ylim([0.1, 1.1]);

yyaxis right
plot(tab(:,1), tab(:,9),'LineWidth',1.2);
ylim([-0.03, 0.06]);
hold on

bands = [1938.5, 1939; 1940.25, 1941.25; 1951.25, 1953.25; 1955, 1959; 1959.5, 1960.75; 1961, 1962; 1962.25, 1963.25; ...
         1966.5, 1967.5; 1968.25, 1968.5; 1968.75, 1978.75; 1979.75, 1981; 1982.25, 1982.75; 1983.25, 1983.5; 1984, 1987; 1987.75, 1988.75; ...
         1990, 1992; 1997, 1998; ...
         1998.5, 1999.75; 2000, 2004; 2008, 2011; 2011.5, 2012.5; 2013, 2014; 2015.5, 2015.75; 2016, 2016.25; 2018, 2019];

xp = [bands fliplr(bands)];
yp = ([[1;1]*min(ylim); [1.2;1.2]*max(ylim)]*ones(1,size(bands,1))).';
for k = 1:size(bands,1)                                                             
    patch(xp(k,:), yp(k,:), [1 1 1]*0.1, 'FaceAlpha', 0.2, 'LineStyle', 'none')
end

ax = gca;
ax.YAxis(1).Color = 'k';
ax.YAxis(2).Color = 'k';

xlim([1935 2020]);
xlabel('Date');
legend('Spread (left)', 'Foreign volatility (right)')
title('b) Spread and Foreign Volatility');

